import { getArticles, getBasicInfo } from '@/api/api';
import ScrollList from '@/components/scroll-list';
import { articleType, queryParamsType } from '@/utils/model';

import dynamic from 'next/dynamic';
export async function getServerSideProps() {
  const [baseInfo, result] = await Promise.all([getBasicInfo(), getArticles()]);
  // console.log('🚀 ~ file: index.tsx:13 ~ getServerSideProps ~ bannerResult:', newsResult.data);
  return {
    props: {
      layout: 'default',
      list: result.data,
      pagationInfo: result,
      baseInfo,
    },
  };
}

const getDynamicComponent = () => {
  const DynamicComponent = dynamic(() => import('@/components/dynamic-example'));
  return <DynamicComponent />;
};
const Home = ({
  list = [],
  pagationInfo,
}: {
  list: articleType[];
  pagationInfo: queryParamsType;
}) => {
  console.log('🚀 ~ file: index.tsx:16 ~ Home ~ list:', list);

  return (
    <>
      {getDynamicComponent()}
      <ScrollList list={list} pageInfo={pagationInfo} />
    </>
  );
};
export default Home;
